<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="被反映人" prop="personName">
        <el-input
          v-model="queryParams.personName"
          placeholder="请输入被反映人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作单位及职务" prop="workUnitPosition">
        <el-input
          v-model="queryParams.workUnitPosition"
          placeholder="请输入工作单位及职务"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主要问题线索" prop="mainClues">
        <el-input
          v-model="queryParams.mainClues"
          placeholder="请输入主要问题线索"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生年月" prop="birthDate">
        <el-input
          v-model="queryParams.birthDate"
          placeholder="请输入出生年月"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入党时间" prop="joinPartyDate">
        <el-input
          v-model="queryParams.joinPartyDate"
          placeholder="请输入入党时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="受理时间" prop="acceptDate">
        <el-input
          v-model="queryParams.acceptDate"
          placeholder="请输入受理时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="处置方式二级分类" prop="dispositionLevel2">
        <el-input
          v-model="queryParams.dispositionLevel2"
          placeholder="请输入处置方式二级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="线索来源" prop="cluesSource">
        <el-input
          v-model="queryParams.cluesSource"
          placeholder="请输入线索来源"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="巡视巡察中发现二级分类" prop="inspectionFindingsLevel2">
        <el-input
          v-model="queryParams.inspectionFindingsLevel2"
          placeholder="请输入巡视巡察中发现二级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="违纪行为" prop="disciplinaryBehavior">
        <el-input
          v-model="queryParams.disciplinaryBehavior"
          placeholder="请输入违纪行为"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="办理结果" prop="handlingResult">
        <el-input
          v-model="queryParams.handlingResult"
          placeholder="请输入办理结果"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="办结时间" prop="completionDate">
        <el-input
          v-model="queryParams.completionDate"
          placeholder="请输入办结时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="组织措施" prop="organizationalMeasures">
        <el-input
          v-model="queryParams.organizationalMeasures"
          placeholder="请输入组织措施"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="证件号码" prop="idNumber">
        <el-input
          v-model="queryParams.idNumber"
          placeholder="请输入证件号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="结案时间" prop="caseClosureDate">
        <el-input
          v-model="queryParams.caseClosureDate"
          placeholder="请输入结案时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="党纪处分" prop="partyDiscipline">
        <el-input
          v-model="queryParams.partyDiscipline"
          placeholder="请输入党纪处分"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="政务处分" prop="governmentalDiscipline">
        <el-input
          v-model="queryParams.governmentalDiscipline"
          placeholder="请输入政务处分"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="其他处理" prop="otherActions">
        <el-input
          v-model="queryParams.otherActions"
          placeholder="请输入其他处理"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:jijianxitong:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:jijianxitong:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:jijianxitong:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:jijianxitong:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="jijianxitongList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" />
      <el-table-column label="被反映人" align="center" prop="personName" />
      <el-table-column label="工作单位及职务" align="center" prop="workUnitPosition" />
      <el-table-column label="主要问题线索" align="center" prop="mainClues" />
      <el-table-column label="出生年月" align="center" prop="birthDate" />
      <el-table-column label="入党时间" align="center" prop="joinPartyDate" />
      <el-table-column label="受理时间" align="center" prop="acceptDate" />
      <el-table-column label="处置方式二级分类" align="center" prop="dispositionLevel2" />
      <el-table-column label="线索来源" align="center" prop="cluesSource" />
      <el-table-column label="巡视巡察中发现二级分类" align="center" prop="inspectionFindingsLevel2" />
      <el-table-column label="违纪行为" align="center" prop="disciplinaryBehavior" />
      <el-table-column label="办理结果" align="center" prop="handlingResult" />
      <el-table-column label="办结时间" align="center" prop="completionDate" />
      <el-table-column label="组织措施" align="center" prop="organizationalMeasures" />
      <el-table-column label="证件号码" align="center" prop="idNumber" />
      <el-table-column label="结案时间" align="center" prop="caseClosureDate" />
      <el-table-column label="党纪处分" align="center" prop="partyDiscipline" />
      <el-table-column label="政务处分" align="center" prop="governmentalDiscipline" />
      <el-table-column label="其他处理" align="center" prop="otherActions" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:jijianxitong:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:jijianxitong:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改纪检系统表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="被反映人" prop="personName">
          <el-input v-model="form.personName" placeholder="请输入被反映人" />
        </el-form-item>
        <el-form-item label="工作单位及职务" prop="workUnitPosition">
          <el-input v-model="form.workUnitPosition" placeholder="请输入工作单位及职务" />
        </el-form-item>
        <el-form-item label="主要问题线索" prop="mainClues">
          <el-input v-model="form.mainClues" placeholder="请输入主要问题线索" />
        </el-form-item>
        <el-form-item label="出生年月" prop="birthDate">
          <el-input v-model="form.birthDate" placeholder="请输入出生年月" />
        </el-form-item>
        <el-form-item label="入党时间" prop="joinPartyDate">
          <el-input v-model="form.joinPartyDate" placeholder="请输入入党时间" />
        </el-form-item>
        <el-form-item label="受理时间" prop="acceptDate">
          <el-input v-model="form.acceptDate" placeholder="请输入受理时间" />
        </el-form-item>
        <el-form-item label="处置方式二级分类" prop="dispositionLevel2">
          <el-input v-model="form.dispositionLevel2" placeholder="请输入处置方式二级分类" />
        </el-form-item>
        <el-form-item label="线索来源" prop="cluesSource">
          <el-input v-model="form.cluesSource" placeholder="请输入线索来源" />
        </el-form-item>
        <el-form-item label="巡视巡察中发现二级分类" prop="inspectionFindingsLevel2">
          <el-input v-model="form.inspectionFindingsLevel2" placeholder="请输入巡视巡察中发现二级分类" />
        </el-form-item>
        <el-form-item label="违纪行为" prop="disciplinaryBehavior">
          <el-input v-model="form.disciplinaryBehavior" placeholder="请输入违纪行为" />
        </el-form-item>
        <el-form-item label="办理结果" prop="handlingResult">
          <el-input v-model="form.handlingResult" placeholder="请输入办理结果" />
        </el-form-item>
        <el-form-item label="办结时间" prop="completionDate">
          <el-input v-model="form.completionDate" placeholder="请输入办结时间" />
        </el-form-item>
        <el-form-item label="组织措施" prop="organizationalMeasures">
          <el-input v-model="form.organizationalMeasures" placeholder="请输入组织措施" />
        </el-form-item>
        <el-form-item label="证件号码" prop="idNumber">
          <el-input v-model="form.idNumber" placeholder="请输入证件号码" />
        </el-form-item>
        <el-form-item label="结案时间" prop="caseClosureDate">
          <el-input v-model="form.caseClosureDate" placeholder="请输入结案时间" />
        </el-form-item>
        <el-form-item label="党纪处分" prop="partyDiscipline">
          <el-input v-model="form.partyDiscipline" placeholder="请输入党纪处分" />
        </el-form-item>
        <el-form-item label="政务处分" prop="governmentalDiscipline">
          <el-input v-model="form.governmentalDiscipline" placeholder="请输入政务处分" />
        </el-form-item>
        <el-form-item label="其他处理" prop="otherActions">
          <el-input v-model="form.otherActions" placeholder="请输入其他处理" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listJijianxitong, getJijianxitong, delJijianxitong, addJijianxitong, updateJijianxitong } from "@/api/system/jijianxitong";

export default {
  name: "Jijianxitong",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 纪检系统表表格数据
      jijianxitongList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        personName: null,
        workUnitPosition: null,
        mainClues: null,
        birthDate: null,
        joinPartyDate: null,
        acceptDate: null,
        dispositionLevel2: null,
        cluesSource: null,
        inspectionFindingsLevel2: null,
        disciplinaryBehavior: null,
        handlingResult: null,
        completionDate: null,
        organizationalMeasures: null,
        idNumber: null,
        caseClosureDate: null,
        partyDiscipline: null,
        governmentalDiscipline: null,
        otherActions: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询纪检系统表列表 */
    getList() {
      this.loading = true;
      listJijianxitong(this.queryParams).then(response => {
        this.jijianxitongList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        personName: null,
        workUnitPosition: null,
        mainClues: null,
        birthDate: null,
        joinPartyDate: null,
        acceptDate: null,
        dispositionLevel2: null,
        cluesSource: null,
        inspectionFindingsLevel2: null,
        disciplinaryBehavior: null,
        handlingResult: null,
        completionDate: null,
        organizationalMeasures: null,
        idNumber: null,
        caseClosureDate: null,
        partyDiscipline: null,
        governmentalDiscipline: null,
        otherActions: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加纪检系统表";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getJijianxitong(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改纪检系统表";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateJijianxitong(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addJijianxitong(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除纪检系统表编号为"' + ids + '"的数据项？').then(function() {
        return delJijianxitong(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/jijianxitong/export', {
        ...this.queryParams
      }, `jijianxitong_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
